﻿@model CurrencySelectorModel
@using Microsoft.AspNetCore.Http
@using System.Net
@using Nop.Core
@inject IWebHelper webHelper
@inject IHttpContextAccessor httpContextAccessor
@if (Model.AvailableCurrencies.Count > 1)
{
    <div class="currency-selector">
        @{
            var currencies = Model.AvailableCurrencies.Select(x => new SelectListItem
            {
                Text = x.Name,
                Value = webHelper.ModifyQueryString(Url.RouteUrl("ChangeCurrency", new { customercurrency = x.Id }), "returnurl=" + WebUtility.UrlEncode(webHelper.GetRawUrl(httpContextAccessor.HttpContext.Request)), null),
                Selected = x.Id.Equals(Model.CurrentCurrencyId)
            });
            <select id="customerCurrency" name="customerCurrency" asp-items="@currencies" onchange="setLocation(this.value);"></select>
        }
    </div>
}